package com.sh.rabbitmq.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@Slf4j
public class ConfirmConfig {

    public static final String QUEUE = "confirm.queue";

    public static final String EXCHANGE = "confirm.exchange";


    @Bean("confirmExchange")
    public DirectExchange confirmExchange(){
        return new DirectExchange(EXCHANGE);
    }

    @Bean("confirmQueue")
    public Queue confirmQueue(){
        return QueueBuilder.durable(QUEUE).build();
    }

    @Bean("queueBindingExchange")
    public Binding queueBindingExchange(@Qualifier("confirmQueue") Queue queue,
                                  @Qualifier("confirmExchange") DirectExchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("key1");
    }
}
